<?php

namespace App\Models\Rooms;

use App\Models\Members;
use App\Models\Room\RoomGoodsBuy;
use App\Models\Room\RoomGoodsMemberCode;
use App\Models\Rooms;
use App\Models\Rooms\GuessinGoods;
use App\Models\Rooms\Room;
use Flaravel\Upload\Fupload;
use Illuminate\Database\Eloquent\Model;

class RoomGoods extends Model
{
    protected $table = 'room_goods';
    protected $fillable = [
        'room_id','room_num','number_of_quiz','goods_id','goods_name','goods_img','goods_member_golden','goods_golden_level','goods_bean','member_id','status','full_time','number_of_quiz_old','buy_back_price','room_goods_rules'
    ];

    public function member()
    {
        return $this->hasOne(Members::class,'id','member_id');
    }

    public function rooms()
    {
        return $this->hasOne(Room::class,'id','room_id');
    }

//    public function getGoodsBeanAttribute($value)
//    {
//        return $this->attributes['goods_bean'] = (int)$value / 10;
//    }

    public function guess_goods()
    {
        return $this->hasOne(GuessinGoods::class,'id','goods_id');
    }

    public function room_goods_codes()
    {
        return $this->hasMany(RoomGoodsMemberCode::class,'room_goods_id','id');
    }


    public function room_goods_buy()
    {
        return $this->hasMany(RoomGoodsBuy::class,'room_goods_id','id');
    }

}
